// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate lazy_static;
extern crate longrunning;
extern crate lro;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// Represents a [Metrics
/// Scope](https://cloud.google.com/monitoring/settings#concept-scope) in Cloud
/// Monitoring, which specifies one or more Google projects and zero or more AWS
/// accounts to monitor together.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MetricsScope {
    /// Immutable. The resource name of the Monitoring Metrics Scope.
    /// On input, the resource name can be specified with the
    /// scoping project ID or number. On output, the resource name is
    /// specified with the scoping project number.
    /// Example:
    /// `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}`
    pub name: std::string::String,

    /// Output only. The time when this `Metrics Scope` was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time when this `Metrics Scope` record was last updated.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The list of projects monitored by this `Metrics Scope`.
    pub monitored_projects: std::vec::Vec<crate::model::MonitoredProject>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl MetricsScope {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::MetricsScope::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::MetricsScope::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::MetricsScope::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::MetricsScope::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::MetricsScope::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [monitored_projects][crate::model::MetricsScope::monitored_projects].
    pub fn set_monitored_projects<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::MonitoredProject>,
    {
        use std::iter::Iterator;
        self.monitored_projects = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for MetricsScope {
    fn typename() -> &'static str {
        "type.googleapis.com/google.monitoring.metricsscope.v1.MetricsScope"
    }
}

/// A [project being
/// monitored](https://cloud.google.com/monitoring/settings/multiple-projects#create-multi)
/// by a `Metrics Scope`.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MonitoredProject {
    /// Immutable. The resource name of the `MonitoredProject`. On input, the resource name
    /// includes the scoping project ID and monitored project ID. On output, it
    /// contains the equivalent project numbers.
    /// Example:
    /// `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`
    pub name: std::string::String,

    /// Output only. The time when this `MonitoredProject` was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl MonitoredProject {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::MonitoredProject::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::MonitoredProject::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::MonitoredProject::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for MonitoredProject {
    fn typename() -> &'static str {
        "type.googleapis.com/google.monitoring.metricsscope.v1.MonitoredProject"
    }
}

/// Request for the `GetMetricsScope` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetMetricsScopeRequest {
    /// Required. The resource name of the `Metrics Scope`.
    /// Example:
    /// `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetMetricsScopeRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetMetricsScopeRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetMetricsScopeRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.monitoring.metricsscope.v1.GetMetricsScopeRequest"
    }
}

/// Request for the `ListMetricsScopesByMonitoredProject` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListMetricsScopesByMonitoredProjectRequest {
    /// Required. The resource name of the `Monitored Project` being requested.
    /// Example:
    /// `projects/{MONITORED_PROJECT_ID_OR_NUMBER}`
    pub monitored_resource_container: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListMetricsScopesByMonitoredProjectRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [monitored_resource_container][crate::model::ListMetricsScopesByMonitoredProjectRequest::monitored_resource_container].
    pub fn set_monitored_resource_container<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.monitored_resource_container = v.into();
        self
    }
}

impl wkt::message::Message for ListMetricsScopesByMonitoredProjectRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.monitoring.metricsscope.v1.ListMetricsScopesByMonitoredProjectRequest"
    }
}

/// Response for the `ListMetricsScopesByMonitoredProject` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListMetricsScopesByMonitoredProjectResponse {
    /// A set of all metrics scopes that the specified monitored project has been
    /// added to.
    pub metrics_scopes: std::vec::Vec<crate::model::MetricsScope>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListMetricsScopesByMonitoredProjectResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [metrics_scopes][crate::model::ListMetricsScopesByMonitoredProjectResponse::metrics_scopes].
    pub fn set_metrics_scopes<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::MetricsScope>,
    {
        use std::iter::Iterator;
        self.metrics_scopes = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListMetricsScopesByMonitoredProjectResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.monitoring.metricsscope.v1.ListMetricsScopesByMonitoredProjectResponse"
    }
}

/// Request for the `CreateMonitoredProject` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateMonitoredProjectRequest {
    /// Required. The resource name of the existing `Metrics Scope` that will monitor this
    /// project.
    /// Example:
    /// `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}`
    pub parent: std::string::String,

    /// Required. The initial `MonitoredProject` configuration.
    /// Specify only the `monitored_project.name` field. All other fields are
    /// ignored. The `monitored_project.name` must be in the format:
    /// `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`
    pub monitored_project: std::option::Option<crate::model::MonitoredProject>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateMonitoredProjectRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateMonitoredProjectRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [monitored_project][crate::model::CreateMonitoredProjectRequest::monitored_project].
    pub fn set_monitored_project<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::MonitoredProject>,
    {
        self.monitored_project = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [monitored_project][crate::model::CreateMonitoredProjectRequest::monitored_project].
    pub fn set_or_clear_monitored_project<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::MonitoredProject>,
    {
        self.monitored_project = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreateMonitoredProjectRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.monitoring.metricsscope.v1.CreateMonitoredProjectRequest"
    }
}

/// Request for the `DeleteMonitoredProject` method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeleteMonitoredProjectRequest {
    /// Required. The resource name of the `MonitoredProject`.
    /// Example:
    /// `locations/global/metricsScopes/{SCOPING_PROJECT_ID_OR_NUMBER}/projects/{MONITORED_PROJECT_ID_OR_NUMBER}`
    ///
    /// Authorization requires the following [Google
    /// IAM](https://cloud.google.com/iam) permissions on both the `Metrics Scope`
    /// and on the `MonitoredProject`: `monitoring.metricsScopes.link`
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeleteMonitoredProjectRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeleteMonitoredProjectRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for DeleteMonitoredProjectRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.monitoring.metricsscope.v1.DeleteMonitoredProjectRequest"
    }
}

/// Contains metadata for longrunning operation for the edit Metrics Scope
/// endpoints.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OperationMetadata {
    /// Current state of the batch operation.
    pub state: crate::model::operation_metadata::State,

    /// The time when the batch request was received.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// The time when the operation result was last updated.
    pub update_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OperationMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [state][crate::model::OperationMetadata::state].
    pub fn set_state<T: std::convert::Into<crate::model::operation_metadata::State>>(
        mut self,
        v: T,
    ) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::OperationMetadata::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::OperationMetadata::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for OperationMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.monitoring.metricsscope.v1.OperationMetadata"
    }
}

/// Defines additional types related to [OperationMetadata].
pub mod operation_metadata {
    #[allow(unused_imports)]
    use super::*;

    /// Batch operation states.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Invalid.
        Unspecified,
        /// Request has been received.
        Created,
        /// Request is actively being processed.
        Running,
        /// The batch processing is done.
        Done,
        /// The batch processing was cancelled.
        Cancelled,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Created => std::option::Option::Some(1),
                Self::Running => std::option::Option::Some(2),
                Self::Done => std::option::Option::Some(3),
                Self::Cancelled => std::option::Option::Some(4),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Created => std::option::Option::Some("CREATED"),
                Self::Running => std::option::Option::Some("RUNNING"),
                Self::Done => std::option::Option::Some("DONE"),
                Self::Cancelled => std::option::Option::Some("CANCELLED"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Created,
                2 => Self::Running,
                3 => Self::Done,
                4 => Self::Cancelled,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "CREATED" => Self::Created,
                "RUNNING" => Self::Running,
                "DONE" => Self::Done,
                "CANCELLED" => Self::Cancelled,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Created => serializer.serialize_i32(1),
                Self::Running => serializer.serialize_i32(2),
                Self::Done => serializer.serialize_i32(3),
                Self::Cancelled => serializer.serialize_i32(4),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.monitoring.metricsscope.v1.OperationMetadata.State",
            ))
        }
    }
}
